<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateNwYbzEcsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('nw_ybz_ecs', function (Blueprint $table) {
            $table->id(); // 主键ID
            $table->string('name')->comment('名称');
            $table->string('resource_type')->comment('资源类型');
            $table->string('region')->comment('区域');
            $table->string('resource_set_id')->comment('所属资源集ID')->nullable();
            $table->string('vdc_id')->comment('所属VDC ID')->nullable();
            $table->string('created_at_utc')->comment('创建时间(UTC+08:00)')->nullable(); // 假定使用当前时间作为默认值
            $table->string('ecs_id')->comment('ecs_id')->nullable();
            $table->uuid('order_number')->comment('申请订单号')->nullable(); // 或者使用 string 类型，根据实际需求调整
            $table->string('resource_group')->comment('所属资源组')->nullable();
            $table->string('image')->comment('镜像')->nullable();
            $table->string('available_zone')->comment('可用分区')->nullable();
            $table->string('expiration_time')->comment('到期时间')->nullable(); // 可能需要手动设置或根据业务逻辑计算
            $table->string('operation_type')->comment('操作类型')->nullable();
            $table->unsignedBigInteger('user_id')->comment('用户ID')->nullable();
            $table->text('description')->comment('描述')->nullable();
            $table->string('status')->comment('状态')->nullable(); // 根据实际需要，可能需要定义为 enum 类型
            $table->string('elastic_ip_address')->comment('弹性IP地址')->nullable();
            $table->string('private_ip_address')->comment('私有IP地址')->nullable();
            $table->string('specification')->comment('规格')->nullable();
            $table->string('is_soft_deleted')->comment('是否软删除')->nullable(); 

            // 外键约束，如果需要的话
  #          $table->foreign('resource_set_id')
  #                ->references('resource_set_name')
  #                ->on('pre_nw_ybz_zyj')
  #                ->onDelete('set null'); // 或 'cascade'
            
            // 可能还需要为user_id添加外键约束，具体表名需根据实际情况调整
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('nw_ybz_ecs');
    }
}